package com.xiashuxia.orgims.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.opensymphony.xwork2.ActionSupport;
import com.xiashuxia.orgims.dao.UserDAO;
import com.xiashuxia.orgims.model.User;

@Repository
public class LoginAction extends ActionSupport{
	/**
	 * 
	 */
	private static final long serialVersionUID = -7050155655676448592L;
	private String username;
	private String password;
	
	@Autowired
	private UserDAO userDAO;
	
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	public String checkLogin() {
		
		User user = userDAO.getUserByUsername(username);
		
		if (this.username.equals(user.getUsername()) && this.password.equals(user.getPassword())) {
			return "success";
		} else {
			return "login";
		}
		/*if (this.username.equals("admin") && this.password.equals("admin")) {
			return "success";
		} else {
			return "login";
		}*/
	}
}
